package com.znsd.zl.app.customize.controller;

import com.znsd.zl.app.customize.entity.CustomizeEntity;
import com.znsd.zl.app.customize.service.CustomizeService;
import com.znsd.zl.utils.BaseController;
import com.znsd.zl.utils.R;
import org.springframework.web.bind.annotation.*;




/**
 * @ClassName TCustomize
 * @Description 描述
 * @author zhangzhou
 * @email jaypdd@163.com
 * @date 2020-08-30 15:42:52
 * @Version v1.0
 */
@RestController
@RequestMapping("/user/customize")
public class CustomizeController extends BaseController<CustomizeService, CustomizeEntity,Integer> {



	@RequestMapping("statusSuccess/{id}")
	public R statusSuccess(@PathVariable("id")Integer id){
		service.setStatusSuccess(id);
		return R.ok("成功");
	}

	@RequestMapping("statusCancel")
	public R statusCancel(@RequestParam String name){
		service.setStatusCancel(name);
		return R.ok("成功");
	}

	@RequestMapping("findByName")
	public R findByName(@RequestParam String name) {
		CustomizeEntity byName = service.findByName(name);
		if (byName==null){
			return R.error();
		}
		return R.ok().put("customize",byName);
	}

	@RequestMapping("isDelete")
	public R isDelete(@RequestParam Integer id){
		try{
			service.isDelete(id);
		}catch (Exception e){
			return R.error("删除失败");
		}

		return R.ok("删除成功");
	}


}
